// BaseRequestHandler.cpp: implementation of the BaseRequestHandler class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "kwservercore.h"
#include "BaseRequestHandler.h"

#include "CommonLib\Packet.h"
#include "CommonLib\Structure.h"

#include "CommServerLib\CommWithClient.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

BaseRequestHandler::BaseRequestHandler(const Packet& packet, HANDLE hClient, bool isRequestEx):
	m_hClient(hClient)
{
	m_pPacket = new Packet;
	*m_pPacket = packet;
	m_hClient = hClient;
	m_bIsRequestEx = isRequestEx;
}

BaseRequestHandler::BaseRequestHandler(const Packet& packet, HANDLE hClient):
	m_hClient(hClient)
{
	m_pPacket = new Packet;
	*m_pPacket = packet;
	m_hClient = hClient;
	m_bIsRequestEx = false;
}

BaseRequestHandler::~BaseRequestHandler()
{
	delete m_pPacket;
}

UnknownRequestHandler::UnknownRequestHandler(const Packet& packet, HANDLE hClient):
	BaseRequestHandler(packet, hClient)
{
}

UnknownRequestHandler::~UnknownRequestHandler()
{
}

bool UnknownRequestHandler::Prehandling()
{
	VizClientServer * pVcs = (VizClientServer *)m_pPacket->GetpData();
	pVcs->m_nMethodAck = VCS_MR_UNKNOWNMETHOD;
	Packet packetAck(sizeof(VizClientServer), (LPBYTE)pVcs);
	packetAck.m_dwId = m_pPacket->m_dwId;

	CommWithClient::Instance()->SendTo(packetAck, m_hClient);

	return true;
}